Passed
Push — master ( 0feaa2...c02782 )
by Dmytro
02:35
created

Reporter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 15
rs 10
c 0
b 0
f 0
1
export default class Reporter {
2
    render(report) {
3
        return report;
4
    }
5
6
    merge(renderedReports) {
7
        return renderedReports;
8
    }
9
10
    run(reports, { prettify }) {
11
        return this.merge(
12
            reports.map(({ label, ...r }) => {
13
                const metrics = prettify
14
                    ? this.prettify(prettify, r)
15
                    : r;
16
17
                return this.render({
18
                    label,
19
                    ...metrics
20
                });
21
            })
22
        );
23
    }
24
25
    prettify(prettifier, obj) {
26
        const res = {};
27
28
        for (const key of Object.keys(obj)) {
29
            res[key] = prettifier(obj[key]);
30
        }
31
32
        return res;
33
    }
34
}
35